<script language="javascript">
<!--
function f_setGrid() {
	f_setDelivery_date();
}

function f_setDelivery_date() {
	document.all("txt_contract_order_detail.st_delivery_date").value = getToday();
	document.all("txt_contract_order_detail.ed_delivery_date").value = getToday();
}

function f_do_query() {
	var st_date = document.all("txt_contract_order_detail.st_delivery_date").value;
	var ed_date = document.all("txt_contract_order_detail.ed_delivery_date").value;

	if (st_date == "" || ed_date == "") return ;

	var where_sql = "";
	var where_type = "";
	var where_value = "";

	if (st_date != "") {
		if (where_sql == "") {
			where_sql = "to_date(to_char(contract_order_detail.st_delivery_date ,'yyyy-mm-dd') ,'yyyy-mm-dd') >= ?";
			where_value = st_date;
			where_type = "date";
		} else {
			where_sql += " and to_date(to_char(contract_order_detail.st_delivery_date ,'yyyy-mm-dd') ,'yyyy-mm-dd') >= ?";
			where_value += ";"+st_date;
			where_type += ";date";
		}
	}

	if (ed_date != "") {
		if (where_sql == "") {
			where_sql = "to_date(to_char(contract_order_detail.ed_delivery_date ,'yyyy-mm-dd') ,'yyyy-mm-dd') <= ?";
			where_value = ed_date;
			where_type = "date";
		} else {
			where_sql += " and to_date(to_char(contract_order_detail.ed_delivery_date ,'yyyy-mm-dd') ,'yyyy-mm-dd') <= ?";
			where_value += ";"+ed_date;
			where_type += ";date";
		}
	}

	var lefttree = window.top.frames("lefttree");
	var funcid = document.all("sfuncID").value;
	var keyid = lefttree.f_getCurItem().keyid;
	if (funcid == "purchase_dept_want") {
		where_sql += " and (contract_order_detail.stock_dept_id = '"+keyid+"')";
	} else {
		where_sql += " and (contract_order.provider_id = '"+keyid+"')";
	}

	alert(where_sql);

	document.all("where_sql").value = where_sql;
	document.all("where_value").value = where_value;
	document.all("where_type").value = where_type;

	f_reloadPage();
}
//-->
</script>
<table class="gridTbl">
<tr class="gridData">
	<td>
	<eam:message key="column.purchase_dept_want.contract_order_detail.st_delivery_date" />:
	<input type="text" id="txt_contract_order_detail.st_delivery_date" name="txt_contract_order_detail.st_delivery_date" value="" class="formEdit" size="12">
	<eam:message key="column.purchase_dept_want.contract_order_detail.ed_delivery_date" />:
	<input type="text" id="txt_contract_order_detail.ed_delivery_date" name="txt_contract_order_detail.ed_delivery_date" value="" class="formEdit" size="12">
	<input type="button" onclick="f_do_query();" value="<eam:message key="btn.keyquery" />" name="query" id="query" class="formData">
	</td>
</tr>
</table>